/**    
 * 文件名：BillManageRest.java</br>
 *    
 * 版本信息：v1.0</br>
 * 日期：2017年7月14日</br>
 * © 2005-2017 雷技信息科技（上海）有限公司版权所有</br>
 *
 */
package com.logic.landseaserver.ws;

import java.util.List;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.logic.common.enums.HttpCodeEnum;
import com.logic.common.util.CommonResult;
import com.logic.common.util.CommonResultMap;
import com.logic.common.util.QueryUtil;
import com.logic.landseaserver.common.exception.LandseaException;
import com.logic.landseaserver.common.util.LoggerHelper;
import com.logic.landseaserver.domain.BalanceSheetRecord;
import com.logic.landseaserver.domain.ViewBillRecord;
import com.logic.landseaserver.models.billmanage.service.BillManageService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 *
 * 项目名称：system-server</br>
 * 类名称：BillManageRest</br>
 * 类描述：账单管理</br>
 * 创建人：Aaron</br>
 * 创建时间：2017年7月14日 下午3:18:24</br>
 * 
 * @version 1.0
 *
 */
@Path("/billmanage")
@Api(value = "账单管理")
public class BillManageRest
{
    private static final Logger LOG = LoggerFactory.getLogger(BillManageRest.class);
    
    @Autowired
    private BillManageService billManageService;
    
    /**
     * 
     * [简要描述]：根据条件查询账单</br>
     * [详细描述]：需要分页</br>
     * [作者]：Aaron(2017-07-14)</br>
     *
     * @param roomId 房间编号
     * @return 结果
     *
     */
    @POST
    @Path("/queryBillByCondition")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "根据条件查询账单")
    public Response queryBillByCondition(@ApiParam(value = "condition", required = true) QueryUtil condition)
    {
        CommonResultMap map = new CommonResultMap();
        try
        {
            condition.getPagingTool().calculateStartIndex();
            
            List<BalanceSheetRecord> queryResultList = billManageService.queryBillByCondition(condition);
            
            // 重新设置记录总数
            Integer totalCount = condition.getPagingTool().getTotalNum();
            map.setResultTotalCount(totalCount);

            map.setData(queryResultList);
            map.setResult(CommonResult.SUCCESS);
        }
        catch (LandseaException e)
        {
            LoggerHelper.handleException(LOG, "queryBillByCondition", e, map);
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }
}
